package io.renren.modules.sys.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.ClientEnquiryDao;
import io.renren.entity.ClientEnquiryEntity;
import io.renren.modules.sys.service.ClientEnquiryService;


@Service("clientEnquiryService")
public class ClientEnquiryServiceImpl extends ServiceImpl<ClientEnquiryDao, ClientEnquiryEntity> implements ClientEnquiryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ClientEnquiryEntity> page = this.selectPage(
                new Query<ClientEnquiryEntity>(params).getPage(),
                new EntityWrapper<ClientEnquiryEntity>()
                        .eq(params.get("sign")!=null&&!params.get("sign").equals(""),"sign",params.get("sign"))
                        .addFilterIfNeed(params.get("searchContent")!=null&&!params.get("searchContent").equals(""),
                                "client_enquiry.name like '%"+params.get("searchContent").toString()+"%' or client_enquiry.phone like '%"+ params.get("searchContent").toString()+"%'")
        );

        return new PageUtils(page);
    }

}
